<?php
namespace app\admin\model;

use think\Model;
use think\facade\Db;

class SysMenu extends Model
{
    public  function getUserMenuList($rid)
    {
        if ($rid === 1) {   // 超级管理员
            $data = $this->field('id, pid, name, url, type, icon')->where('type', '<>', 2)->select();
        } else {
            $roleModel = new SysRole();
            $permission_ids = $roleModel->getpermissionIds($rid);
            $data = $this->where('id', 'IN', $permission_ids)->where('type', '<>', 2)->field('id, pid, name, url, icon')->select();
        }

        return $data;
    }
}
